package com.rimi.controller;

import com.rimi.bean.Exhibition;
import com.rimi.commons.CommonsDataResult;
import com.rimi.commons.CommonsResult;
import com.rimi.commons.ResultStaus;
import com.rimi.service.ExhibitionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @
 * @author:liangLi
 * @time:2020/7/6 19:54
 */
@CrossOrigin
@Controller
@Api(value = "轮播图" ,description = "轮播图")
public class ExhibitionController {
    @Autowired
    ExhibitionService exhibitionService;

    @GetMapping("/rotation")
    @ResponseBody
    @ApiOperation("显示轮播图")
//    public List<String> showRotation(){

    public CommonsDataResult showRotation(){
        List<Exhibition> rotationImages = exhibitionService.getExhibitionWithImage();
        List<String> list=new ArrayList<>();
        for (Exhibition rotationImage : rotationImages) {
            String mzImage = rotationImage.getMzImage();
            list.add(mzImage);
        }

        if (list.size()==0){
            return new CommonsDataResult(ResultStaus.EXCEPTION_ERROR,list);
        }else{
            return new CommonsDataResult(ResultStaus.OK,list);
        }


    }
}
